﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using QMERP.Domain.Entities;

namespace QMERP.Infrastructure.EFCore.Mappings
{
    public class LensMapping : IEntityTypeConfiguration<Lens>
    {
        public void Configure(EntityTypeBuilder<Lens> builder)
        {
            builder.HasQueryFilter(x => x.IsEnable);
            builder.Property(x => x.SalesLensCode).HasMaxLength(400);
            builder.Property(x => x.SalesLensName).HasMaxLength(400);
            builder.Property(x => x.FactoryLensCode).HasMaxLength(400);
            builder.Property(x => x.FactoryLensName).HasMaxLength(400);
            builder.Property(x => x.Description).IsRequired(false).HasMaxLength(400);
            builder.Property(x => x.Brand).HasMaxLength(20);
            builder.Property(x => x.LensType).HasMaxLength(10);
            builder.Property(x => x.MaxSPH);
            builder.Property(x => x.MinSPH);
            builder.Property(x => x.MaxCYL);
            builder.Property(x => x.MinCYL);
            builder.Property(x => x.MaxADD);
            builder.Property(x => x.MinADD);
            builder.Property(x => x.Size).HasMaxLength(400);
            builder.Property(x => x.CGPrice).HasPrecision(18, 2);
            builder.Property(x => x.Price).HasPrecision(18, 2);
            builder.Property(x => x.ProductType).HasMaxLength(5);
            builder.Property(x => x.Type).HasMaxLength(50);
            builder.Property(x => x.Refraction).HasMaxLength(50);
            builder.Property(x => x.Transition);
            builder.Property(x => x.Vouchers);
            builder.Property(x => x.Color).HasMaxLength(100);
            builder.Property(x => x.Corridor).IsRequired(false).HasMaxLength(100);
            builder.Property(x => x.Mirror).HasMaxLength(100);
            builder.Property(x => x.Tinting).IsRequired(false).HasMaxLength(100);
            builder.Property(x => x.Coating).HasMaxLength(100);
            builder.Property(x => x.Cost).HasPrecision(18, 2);
            builder.Property(x => x.TechnologyCode).IsRequired(false).HasMaxLength(10);
            builder.Property(x => x.FocusCode).IsRequired(false).HasMaxLength(10);
            builder.Property(x => x.ApplyCode).IsRequired(false).HasMaxLength(10);
            builder.Property(x => x.TextureCode).IsRequired(false).HasMaxLength(10);
            builder.Property(x => x.Unit).IsRequired(false).HasMaxLength(10);

            builder.Property(x => x.CurrencyId);

            builder.HasIndex(x => x.Id);
            builder.HasIndex(x => x.CurrencyId);
            builder.HasIndex(x => x.SalesLensCode);
            builder.HasIndex(x => x.SalesLensName);
            builder.HasIndex(x => x.FactoryLensCode);
            builder.HasIndex(x => x.FactoryLensName);
            builder.HasIndex(x => x.LensType);
            builder.HasIndex(x => x.ProductType);
            builder.HasIndex(x => x.Type);
            builder.HasIndex(x => x.CreatedOn).IsDescending();
        }
    }
}
